package com.jysz.certificate.persistence.dao.workflow;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.jysz.certificate.persistence.dao.AbstractBaseDao;
import com.jysz.certificate.persistence.enums.WorkflowType;
import com.jysz.certificate.persistence.model.workflow.Workflow;

/**
 * 
 * @author xuxiaolong
 */
@Repository
public class WorkflowDao extends AbstractBaseDao<Workflow, Long> {

	public Workflow find(WorkflowType type,Long objId){
		Query query=getSession().createQuery("select w from Workflow w ,WorkflowObject wo where w.id=wo.workflow.id and w.type=? and wo.objectId=?");
				
		query.setInteger(0, type.getIndex());
		query.setLong(1, objId);
		List<Workflow> list=query.list();
		if(list!=null&&list.size()>0)
			return list.get(0);
		return null;
	}
}
